<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/admittance.css')}}">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>

@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
      @include('web.layout.seller_nav')
      <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">合同信息</div>
                <div class="content">
                    <div class="tishi">
                        电子合同是e井在线平台与第三方平台合作为企业及个人用户推出的中立、公证、可信、安全、合法合规的电子合同签约服务，用户可以在平台上实现多方在线签订合同、协同管理及合同法律支持。<a href="http://b2b.ejing365.com/helper/detail/741">了解更多</a>
                    </div>
                    <div class="mrtop">
                        <span class="fl">提示：为保证买卖双方合同签署的法律效力，请及时认证并授权开通电子合同。</span>
                    </div>
                    <div class="identification_box fl ml215">
                        <img src="{{asset('../../img/web/user/admittance_icon_01.png')}}">
                        <span>会员身份认证</span>
                        <font class="complete">已完成企业认证</font>
                        <p>企业三证信息的认证</p>
                        <p>让合同双方身份更真实更有效！</p>
                    </div>
                    <img class="jinatou" src="{{asset('../../img/web/user/jiantou.png')}}">
                    <div class="identification_box fl">
                        <img src="{{asset('../../img/web/user/admittance_icon_02.png')}}">
                        <span>会员身份认证</span>
                        <font class="unauthorized">未授权</font>
                        <p>公司授权合同签署代理人</p>
                        <p>让合同签署过程更安全！</p>
                        <div class="authorization_btn">立即授权</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="authorization_main">
    <div class="authorization_main_box">
        <form  method="post" id="authorization-post">
            <div class="authorization_main_top fl">
                <font>电子合同授权</font>
                <span>×</span>
            </div>
            <div class="input_box fl">
                <span>机构名称</span>
                {{$company_name}}
                <input class="name" type="hidden" name="name" value="{{$company_name}}">
                <input class="name" type="hidden" name="company_address" value="{{$company_address}}">
                
            </div>
            <div class="input_box fl">
                <span>社会信用代码</span>
                <input class="organCode" type="text" name="organCode" value="">
            </div>
            <div class="input_box fl">
                <span>授权类型</span>
                <label><input type="radio" class="userType" name="userType" value="1" checked="checked">代理人授权</label>
                <label><input type="radio" class="userType" name="userType" value="2">法人授权</label>
            </div>
            <div class="input_box fl">
                <span>授权姓名</span>
                <input class="agentName" type="text" name="agentName" value="">
            </div>
            <div class="input_box fl">
                <span>授权人身份证</span>
                <input class="agentIdNo" type="text" name="agentIdNo" value="">
            </div>
            <div class="input_box fl">
                <span>手机号</span>
                <font class="phone">{{$mobile}}</font>
                
                <input type="button" class="fr code-btn" id="getcode" value="获取验证码">
                <div class="fr" id="timer"></div>
                <input style="width: 70px;" class="verify_code fr" type="text" name="code" value="">
                <font class="fr">验证码</font>
            </div>
            <div class="btn_box fl">
                <div class="authorization_confirm_btn fr">确认</div>
            </div>
            <input type="hidden" value="{{$mobile}}" name="phone"/> 
        </form>
    </div>
</div>
@include('web.layout.footer')
<script type="text/javascript">
$(function(){
    $('.authorization_confirm_btn').click(function () {
        var name = $("input[name='name']").val();
        if (name == '') {
            layer.alert('请输入机构名称', {
                icon: 2
            });
            return false;
        }
        var organCode = $("input[name='organCode']").val();
        if (organCode == '') {
            layer.alert('请输入社会信用代码', {
                icon: 2
            });
            return false;
        }
        var agentName = $("input[name='agentName']").val();
        if (agentName == '') {
            layer.alert('请输入授权姓名', {
                icon: 2
            });
            return false;
        }
        var agentIdNo = $("input[name='agentIdNo']").val();
        if (agentIdNo == '') {
            layer.alert('请输入授权人身份证', {
                icon: 2
            });
            return false;
        }
        var verify_code = $("input[name='verify_code']").val();
        if (verify_code == '') {
            layer.alert('请输入验证码', {
                icon: 2
            });
            return false;
        }
        $.ajax({
            url: '/member/buyer/order_contract/contract_auth',
            type: 'POST',
            dataType: 'json',
            data: $("#authorization-post").serializeArray(),
            success: function (data) {
                if (data.status == 1) {
                    layer.msg('授权成功');
                    $('.authorization_main').hide();
                    location.reload();
                } else {
                    layer.alert(data.msg, {
                        icon: 0
                    });
                }
            }

        })
    })
    $('.authorization_btn').click(function () {
        $('.authorization_main').show();
    })
    $('.authorization_main_top span').click(function () {
        $('.authorization_main').hide();
        $(".authorization_main input[type='text']").val('');
    })

    //获取短信验证码
    $('.code-btn').click(function () {
        //ajax提交获取
        var phone = $(".phone").html();
        $.ajax({
            url: '/member/buyer/order_contract/sendsms',
            type: 'POST',
            dataType: 'json',
            data: {phone: phone},
            success: function (data) {
                if (data.code == 0) {
                    var mytime = myDate.getTime(); //获取当前时间戳
                    var endMytime = mytime + 1000 * 60; //计算结束时间戳
                    $.cookie("endMytime", endMytime, {expires: endMytime});
                    $.cookie("phone", phone);
                    maxtime = 59;
                    timer = setInterval(CountDown, 1000);
                    $("#getcode").hide();
                    $("#timer").html('60秒').show();
                    maxtime_phone = 5;
                    timer_phone = setInterval(CountDown_phone, 1000);
                    layer.alert(data.message, {
                        icon: 0
                    });

                } else {
                    layer.alert(data.message, {
                        icon: 2
                    });
                }
                ;
            }
        })

    })


//获取短信验证码倒计时

    var myDate = new Date();
    var newTime = myDate.getTime();
    var timePoor = $.cookie("endMytime") - newTime;
    var maxtime_phone = 0;
    var timer_phone;
    if (timePoor < 0) {
        $.cookie("endMytime", null); //使cookie失效
    }
    var maxtime;
    maxtime = parseInt(timePoor / 1000);
    var timer;
    if (maxtime > 0) {
        CountDown();
        timer = setInterval(CountDown, 1000);
    }

    function CountDown() {
        if (maxtime >= 0) {
            $("#getcode").hide();
            $("#timer").show();
            seconds = Math.floor(maxtime % 60);
            msg = seconds + "秒";
            $("#timer").html(msg);
            $("#getcode").val(msg);
            if (maxtime < 56) {
                $(".phone-tips").hide();
            }
            --maxtime;
            window.name = maxtime;
        } else {
            clearInterval(timer);
            $("#getcode").show();
            $("#timer").hide();
            $("#getcode").val("获取验证码");
        }
    }

    function CountDown_phone() {
        if (maxtime_phone > 0) {
            seconds_phone = Math.floor(maxtime_phone % 60);
            $("#timephone").html(maxtime_phone);

            --maxtime_phone;
            window.name = maxtime_phone;
        } else {
            clearInterval(timer_phone);
        }
    }

    //获取短信验证码倒计时结束


})
</script>
</body>
</html>